package com.beadwallet.alarm.base.datasource;

import com.beadwallet.alarm.config.DataSourceType;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @author author:xinjing.wang
 * @version date：2015年11月17日 下午2:04:10
 * 类说明
 */
@Aspect
@Order(-1)
@Component
public class DataSourceAspect {
    private static final Logger log = LoggerFactory.getLogger(DataSourceAspect.class);

    @Pointcut("execution(* com.beadwallet.alarm.service.reviewUser..*.*(..))")
    public void pointCut() {
    }


    @Before("pointCut()")
    public void setCenterUserDataSourceType() throws Exception {
        HandleDataSource.putDataSource(DataSourceType.user_center.getType());
        log.info("dataSource == >: centerUser");
    }


    @After("pointCut()")
    public void afterReturning() throws Throwable {
        HandleDataSource.clearDataSource();
        log.debug("=====> clear datasource aop ");
    }


}
